﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Drawing;

namespace GameStudio.Common.GFX
{
    public class FillMesh
    {
        private List<Node> t;
        public FillMesh()
        {
            t = new List<Node>();
        }
        public void ReadXmlImage(string Path)
        {
            string Positions;
            //string[] Nodes;
            string ColorShape;
            XmlDocument doc = new XmlDocument();
            doc.Load(Path);

            foreach (System.Xml.XmlElement node in doc.GetElementsByTagName("Voxel"))
            {
                //XmlNode myElem = node.GetElementsByTagName("Voxel")[0];//.getAttribute("Positions");
                Positions = node.Attributes.GetNamedItem("Position").Value;
                ColorShape = node.Attributes.GetNamedItem("Colour").Value;
                //Nodes = Positions.Split(' ');
                t.Add(AddTriangle(Positions));
            }
        }
        public void AssignTriangleToUser()
        {
            Object UserObject = new Object();
            UserObject.Init(t.ToArray());
        }
        private Node AddTriangle(string Nodes)
        {
            Node MyTr = new Node();
            //Node[] nodes = new Node[3];
            string[] Positions;
            for (int i = 0; i < Nodes.Length; i++)
            {
                Positions = Nodes.Split(',');
                
                MyTr._XPosition = Convert.ToDouble(Positions[0]);
                MyTr._YPosition = Convert.ToDouble(Positions[1]);
                MyTr._ZPosition = Convert.ToDouble(Positions[2]);
                
            }
            return MyTr;
        }
    }
}
